<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<style type="text/css">
    .error{
        color:red;
    }
    .show1{
        display:none;
    }
</style>
<head>
    <title>登录界面</title>
    <link rel="stylesheet" href="resource/statics/css/materialize.css">
    <link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <meta charset="utf-8">
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
</head>
<body style="background:url(resource/images/5.jpeg) ;-webkit-background-size: cover;background-size:cover;">
<div class="container">
    <div class="row" style="margin: 150px 0 40px 0;">
        <div class="col s6 offset-s3 card-panel" style="background-color: rgba(255,255,255,0.5);-webkit-border-radius: 20px;-moz-border-radius: 20px;border-radius: 20px;">
            <form class="bs-example bs-example-form" action="login.do" method="post" role="form">
                <div class="row" style="display: flex; justify-content: center; align-items: center;">
                    <p style="font-family: 微软雅黑; align-items: center; color: rgb(70,130,180); font-size: 25px;font-weight: bold;margin-bottom: 10px;margin-top: 10px;">用户登录</p>
                </div>
                <div class="input-group col s10 offset-s1" style="margin-bottom: 10px;width: 80%;">
                    <label class="input-group-addon" id="basic-addon1" style="height: 60px;">账号</label>
                    <input type="text" class="form-control" id="username" name="username" placeholder="Username" aria-describedby="basic-addon1" style="height: 60px;font-size: 1.5rem;">
                    <span id="spanname" class="error show1">(用户名应该在2到10个字符之内)</span>
                </div>
                <div class="input-group col s10 offset-s1" style="margin-bottom: 30px;width: 80%;">
                    <span class="input-group-addon" id="basic-addon2" style="height: 60px;">密码</span>
                    <input type="password" class="form-control" id="password" name="password" placeholder="Password" aria-describedby="basic-addon2" style="height: 60px;font-size: 1.5rem;">
                    <span id="spanpassword" class="error show1">(密码应该在6到15个字符之内)</span>
                </div>
                <div class="button" style="text-align: center;margin-bottom: 30px;">
                    <button class="btn waves-effect waves-light" disabled="disabled" type="submit" id="submit" name="action" style="background-color: rgb(70,130,180);font-size: 20px;width: 200px;">
                        登录
                    </button>
                </div>
                <div class="button">
                    <div align = "right";class="btn-group" role="group" aria-label="..." style="left: 9%;margin-bottom: 10px;">
                        <button type="button" class="btn btn-link" onclick='location.href=("adlogin.jsp")'>后台登录</button>
                        <button type="button" class="btn btn-link" onclick='location.href=("register.jsp")'  style="float:left;">注册账号</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    //检查正确性
    $("#username").keyup(function(){

        if($.trim($("#password").val()).length != "")
        {
            if($.trim($("#username").val()).length == "" || $.trim($("#username").val()).length < 2 || $.trim($("#username").val()).length > 10) {
                $("#spanname").css("display","block");
                $("#submit").attr("disabled","disabled");
            } else {
                $("#spanname").css("display","none");
                $("#submit").removeAttr("disabled");
            }
        }else {
            if($.trim($("#username").val()).length == "" || $.trim($("#username").val()).length < 2 || $.trim($("#username").val()).length > 10) {
                $("#spanname").css("display","block");
            } else {
                $("#spanname").css("display","none");
            }
        }
    });
    $("#password").keyup(function(){
        if(($.trim($("#username").val()).length == "" || $.trim($("#username").val()).length < 2 || $.trim($("#username").val()).length > 10)||
            ($.trim($("#password").val()).length == "" || $.trim($("#password").val()).length < 6 || $.trim($("#password").val()).length > 15) )
           {
            $("#spanpassword").css("display","block");
            $("#submit").attr("disabled","disabled");
        } else {
            $("#spanpassword").css("display","none");
            $("#submit").removeAttr("disabled");
        }
    });

</script>
</body>
</html>
